<!-- start: Wrapper -->
        <table class="zebra-striped">
            <thead>
            <tr>
                <th>Thành viên</th>
                <th>Nội dung</th>
                <th>Tình trạng</th>
                <th>Xử lý</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($message as $item){ ?>
            <tr id="<?php echo $item->id ?>">

                    <td><?php echo $item->from_user_name; ?></td>
                    <td><?php echo $item->message_content; ?></td>
                    <td> <?php
                        $result = \Velacolib\Utility\Utility::Messge_status_class($item->is_accepted);
                        ?>
                        <span class="<?php echo $result['class'] ?>"><?php echo $result['type'] ?></span>
                    </td>
                <?php if($item->type_request == 0){ ?>
                <td class="center">
                    <button class="bt_Accept btn btn-mini btn-primary" data-message-id="<?php echo $item->id ?>" data-friend-id="<?php echo $item->form_user ?>" data-user-id="<?php echo $item->to_user ?>" data-follow="<?php echo $item->type_request ?>" >Chấp nhận</button>
                    <button class="btn btn-mini btn-danger  btn_delete" data-message-id="<?php echo $item->id; ?>">Xóa</button>
                </td>

            </tr>
            <?php
            }else{?>

                    <td class="center">
                        <button class="btn_replay btn btn-mini btn-primary" data-message-id="<?php echo $item->id ?>" data-friend-id="<?php echo $item->form_user ?>" data-user-id="<?php echo $item->to_user ?>" data-follow="<?php echo $item->type_request ?>"  >Trả Lời</button>
                        <button class="btn btn-mini btn-danger  btn_delete" data-message-id="<?php echo $item->id; ?>">Xóa</button>
                    </td>
               <?php }
            } ?>

            </tbody>
        </table>

    <!-- end: Container -->
</div>
<!-- end: Wrapper -->
<script>

        $('.bt_Accept').click(function(){

            var friend_id = $(this).attr('data-friend-id');
            var user_id = $(this).attr('data-user-id');
            var follow = $(this).attr('data-follow');
            var message_id = $(this).attr('data-message-id');
            $.ajax({
                url: '/admin/user/acceptfriend',
                type: 'post',
                data : {user_id: user_id,friend_id: friend_id, follow: follow, message_id: message_id }
            }).done(function(data){
                    if(data == 0){
                        var content = 'Thêm bạn thành công';
                        $("tr#"+message_id).remove();
                        jsuccess(content);
                    }
                    else{
                        var content = 'Oops DoneUser existing in your friend list';
                        jerror(content);
                    }

                })
        })

        //delete message
        $('.btn_delete').click(function(){
            var message_id = $(this).attr('data-message-id');
            $.ajax({
                url: '<?php echo $this->url('admin/child',array('controller'=>'user','action'=>'loademail')) ?>',
                type: 'post',
                data : {
                    message_id: message_id
                }
            }).done(function(data){
                    $("tr#"+message_id).remove();
                    jsuccess('Success!');
                });
        })


</script>